package com.ericom.model;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
@Table(name="delivery_address")
public class DeliveryAddress extends BaseObject{

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", id)
				.append("address", address).append("city", city).toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof DeliveryAddress))
			return false;
		DeliveryAddress castOther = (DeliveryAddress) other;
		return new EqualsBuilder().append(id, castOther.id)
				.append(address, castOther.address).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).append(address).toHashCode();
	}

	private Long id;
	private String address;
    private String city;
    private String province;
    private String country;
    private String postalCode;
    private String phone;
    private String mobile;
    private String consignee;
    public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	private Member member;
    @Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@ManyToOne(cascade = { CascadeType.MERGE })  
	@JoinColumn(name = "member_id")	
	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getPostalCode() {
		return postalCode;
	}

	public void setPostalCode(String postalCode) {
		this.postalCode = postalCode;
	}
    
}
